home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / win / newpap.zip / NEWPAPER.C next >
Text File  |  1990-08-30  |  2KB  |  79 lines

  1. /*
  2.  **************************************************************
  3.  * newpaper.c                                                 *
  4.  * 7/28/90 by Jim Button                                      *
  5.  *------------------------------------------------------------*
  6.  * Updates WIN.INI Wallpaper specification to point to the    *
  7.  *   to the next BMP file in the windows subdirectory.        *
  8.  *                                                            *
  9.  *                                                            *
  10.  * This hardly looks like a Windows program. The traditional  *
  11.  *   message loop is not even needed, since it does no input, *
  12.  *   has no output, and terminates almost before it starts!   *
  13.  **************************************************************
  14.  */
  15.  
  16. #ifndef _WINDOWS
  17. #define _WINDOWS
  18. #endif
  19.  
  20. #include <windows.h>
  21. #include <sys/types.h>
  22. #include <sys/stat.h>
  23. #include <dos.h>
  24. #include <string.h>
  25.  
  26. static char msg[]       = " By Jim Button ";
  27. static char WallPaper[] = "Wallpaper";
  28.  
  29. #define MAX_PROF_STR  13
  30.  
  31.  
  32. int PASCAL WinMain(  HANDLE hInstance,
  33.                      HANDLE hPrevInstance,
  34.                      LPSTR lpszCmdLine,
  35.                      int nCmdShow)
  36. {
  37.    unsigned int done;
  38.    char oldbmp[MAX_PROF_STR+1];
  39.    char firstbmp[MAX_PROF_STR+1];
  40.    char newbmp[MAX_PROF_STR+1];
  41.    struct  find_t dta;
  42.    struct  stat   buf;
  43.    char *tiled;
  44.  
  45.    GetProfileString("Desktop", WallPaper, "", oldbmp, MAX_PROF_STR);
  46.    newbmp[0] = '\0';                            /* In case no BMP files exist */
  47.  
  48.    /*** Get the list of .BMP files ***/
  49.    done = _dos_findfirst("*.BMP", 0, &dta);     /* Find files */
  50.    if (!done) {
  51.       strcpy(firstbmp, dta.name);
  52.       strcpy(newbmp, firstbmp);
  53.    }
  54.  
  55.    while (!done) {
  56.       if (!strcmpi(dta.name, oldbmp)) {         /* Current one? */
  57.           done = _dos_findnext(&dta);
  58.           strcpy(newbmp, (done ? firstbmp : dta.name));
  59.           break;
  60.       }
  61.       done = _dos_findnext(&dta);
  62.    }
  63.  
  64.    /*** Update WIN.INI ***/
  65.    WriteProfileString("Desktop", WallPaper, newbmp);
  66.  
  67.    /*** if filesize < 100K, use "tiled" ***/
  68.    tiled = "0";                                 /* Point to string "0" */
  69.    if (stat(newbmp,&buf) != -1)
  70.        if (buf.st_size < 100000L)
  71.            tiled = "1";                         /* Point to string "1" */
  72.    WriteProfileString("Desktop", "TileWallpaper", tiled);
  73.  
  74.    return(FALSE);
  75. }
  76.  
  77.  
  78.  
  79.